<template>
  <div>
    <!-- v-bind="$attrs" 展开$attrs  -->
    <input :type="type" :value="value" @input="onInput" v-bind="$attrs">
  </div>
</template>

<script>
export default {
  inheritAttrs: false, // 设置为false避免attrs设置到根元素上
  name: "KInput",
  props: {
    value: {
      type: String,
    },
    type: {
      type: String,
      default: 'text',
    }
  },
  methods: {
    onInput(e) {
      //vue3 新变化 emit触发组件值变化不用指定监听事件了，直接update:值
      this.$emit('update:value', e.target.value)

      this.$mybus.emit('validate')
    }
  }
}
</script>

<style scoped>

</style>